<?php

namespace App\Exports\Game\Data\Settlement\Elasticsearch;

use App\Exports\Game\Data\Settlement\InfoExport as Export;

class InfoExport extends Export
{

    /**
     * 映射数据行
     *
     * @param array $item
     * @return array
     */
    protected function map($item): array
    {
        $item = $item['_source'];

        return [
            $item['sn'],
            $item['uid'],
            $item['line_code'],
            $this->orgs[$item['plat_code']]['name'] ?? $item['plat_code'],
            $item['account_id'],
            $this->games[$item['game_id']] ?? $item['game_id'],
            $item['currency'],
            $item['bet_base'],
            $item['bet_num'],
            $item['gain_player'],
            $item['gain_sys'],
            $item['balance_start'],
            $item['balance_end'],
            $this->playerTypeList[$item['player_type']] ?? $item['player_type'],
            $this->statusList[$item['status']] ?? $item['status'],
            timestamp_to_datetime($item['start_time']),
            timestamp_to_datetime($item['end_time']),
            $item['usd']['rate'] ?? null,
            $item['usd']['bet_base'],
            $item['usd']['bet_num'],
            $item['usd']['gain_player'],
            $item['usd']['gain_sys'],
            $item['usd']['balance_start'],
            $item['usd']['balance_end'],
        ];
    }

    /**
     * 初始化操作
     */
    protected function init()
    {
        parent::init();

        // 初始化平台列表
        $this->initOrgs();
    }
}
